<?php echo form_open_multipart(uri_string())?>    
    <table class="form">
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_customer');?></td>
            <td>
                <select id="position" name="adv_customer_id" class="w300">
                     <?php 
                     foreach($adv_customer as $customer){
                         echo '<option value="'.$customer->adv_customer_id.'">'.$customer->adv_customer_name.'</option>';
                     }
                    ?>
                </select>
            </td>
        </tr> 
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_page');?></td>
            <td>
                 <select name ="adv_page_id" id="adv_page_id">
                        <option value="">Trang quảng cáo</option>
                        <?php 
                            foreach($list_page as $page){
                                echo '<option '.(($item->adv_page_id==$page->adv_page_id)?'selected="true"':'').' value="'.$page->adv_page_id.'">'.$page->adv_page_name.'</option>';
                            }
                        ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_position');?></td>
            <td id="adv_position_opt">
                <select id="adv_position_id" name="adv_position_id" class="w300">
                     <option value="">Vị trí</option>
                </select>
            </td>
        </tr> 
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_name');?></td>
            <td><input type="text" name="adv_title" id="adv_title" class="w250" value=""></td>
        </tr> 
         <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_name_en');?></td>
            <td><input type="text" name="adv_title_en" id="adv_title_en" class="w250" value=""></td>
        </tr>

        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_banner_file_type');?></td>
            <td>
                <select id="position" name="adv_file_type" class="w100">
                    <option value="IMG">Hình ảnh</option>
                    <option value="FLA">Flash</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_url');?></td>
            <td><input type="text" name="adv_url" id="adv_url"class="w350" value=""></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_link');?></td>
            <td><input type="text" name="adv_link" class="w350" value=""></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_file');?></td>
            <td><input type="file" name="adv_file" /></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_link_en');?></td>
            <td><input type="text" name="adv_link_en" class="w350" value=""></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_file_en');?></td>
            <td><input type="file" name="adv_file_en" /></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_order');?></td>
            <td><input type="text" name="nb_order" id="nb_order"class="w100" value=""></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_dt_start');?></td>
            <td>
                <input type="text" name="dt_start" id="dt_start" class="w100" value="">
                 <script type="text/javascript">
                    var cal = Calendar.setup({
                      onSelect: function(cal) { cal.hide();}
                      });
                      cal.manageFields("dt_start", "dt_start","%d/%m/%Y");
                 </script>
            </td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_dt_end');?></td>
            <td>
                <input type="text" name="dt_end" id="dt_end" class="w100" value="">
                <script type="text/javascript">
                    var cal1 = Calendar.setup({
                      onSelect: function(cal) { cal.hide();}
                      });
                      cal1.manageFields("dt_end", "dt_end","%d/%m/%Y");
                 </script>
            </td>
        </tr>
        <tr>
            <td class="label"><?php echo lang('active_deactive');?></td>
            <td>
                <select name="bl_active">
                    <option value="1">Kích hoạt</option>
                    <option selected="true" value="0">Đợi</option>
                    <option value="-1">Kết thúc</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" name="bt_submit" value="" class="luu">
            </td>
        </tr>  
    </table>
<?php echo form_close()?>
<script type="text/javascript" language="javascript">
    function loadPosition(id_page){
        $.ajax({
            type: "POST",
            url: BASE_URI+"adv/get_position/",
            data: {
                'adv_page_id':id_page
            },
            dataType: 'html',
            async:true,
            error: function (request, status, error){

            },
            success: function(data) {
                $('#adv_position_opt').html(data);
            }
        });
    }
    $(document).ready(function(){
		$("#adv_page_id").change(function(){
            loadPosition($(this).val());
		});
	});
</script>